package com.yyge.vo;

import com.github.pagehelper.PageInfo;

//将分页查询结果封装到业务逻辑层
public class PageVo {
    /**
     * 将分页查询结果封装到pageVo对象
     */

     private Integer pageNum;
     private Integer pageSize;

     // 符合条件的数据总共有多少条
     private  Long total;

     //分页查询的数据
     private Object data;

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static <E> PageVo of(PageInfo<E> pageInfo){
        //从pageInfo 提取total ,list ,封装为一个PageVo的对象
        PageVo pageVo=new PageVo();
        pageVo.setPageNum(pageInfo.getPageNum());
        pageVo.setPageSize(pageInfo.getPageSize());
        pageVo.setTotal(pageInfo.getTotal());
        pageVo.setData(pageInfo.getList());
        return pageVo;
    }
}
